using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Common
{
    public class TableItems
    {
        private Dictionary<string, Type> fields;
        private DataTable dataTable;

        public TableItems()
        {
            dataTable = new DataTable();
            fields = new Dictionary<string, Type>();
        }

        public void AddField(string field, Type type)
        {
            fields.Add(field, type);
            dataTable.Columns.Add(field, type);
        }

        public void AddValues(params object[] values)
        {
            int pos = 0;
            DataRow dr = dataTable.NewRow();
            foreach (DataColumn column in dataTable.Columns)
            {
                dr[column] = values[pos];
                pos++;
            }
            dataTable.Rows.Add(dr);
        }

        public DataTable GenerateDataTable()
        {
            return dataTable;
        }
    }
}
